<template>
	<view class="content mainpadding2">
		<view class="bankCard margin_top" v-for="item in list" :key="item.id" @click="jumpdetail(item)">
			<view class="num">{{item.cardno}}</view>
			<view class="flexbetween margin_top">
				<view class="flexleft">
					<view class="color_ling text_b margin_right2">{{item.bank.name}}
					</view>
					<view class="line margin_right2"></view>
					<view class="xiaolan">{{item.username}}</view>
				</view>
				<view class="flexleft" @click.stop="delBanke(item.id)">
					<u-icon name="trash" size="19" color="#3B50FF"></u-icon>
				</view>
			</view>
		</view>
		<view class="gudingdb mainpadding">
			<view class="bigbtn" @click="jumpurl('/pages/mine/tianjiayhk')">
				添加银行卡
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				list: [],
				type:0
			}
		},
		onLoad(options) {
			if(options.type){
				this.type = options.type
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init() {
				httpRequest.request('/api/user/userBankIndex', 'GET', {
				}).then(res => {
					this.list = res.data
				})
			},
			delBanke(id) {
				httpRequest.modal('提示', '是否确认删除？', true, (resp) => {
					if (resp) {
						httpRequest.request('/api/user/delUserBank', 'POST', {
							id
						}).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								this.init()
							}
						})
					}
				})

			},
			jumpdetail(item){
				if(this.type==1){
					uni.$emit("checkyhkfn",item)
					uni.navigateBack(1)
					return false
				}
				uni.navigateTo({
					url: "/pages/mine/tianjiayhk?id=" + item.id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding-bottom: 150rpx;
	}

	.bankCard {
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		border: 2rpx solid #3B50FF;
		padding: 40rpx;

		.num {
			font-size: 48rpx;
			font-family: DIN Next LT Pro-Medium, DIN Next LT Pro;
			font-weight: 500;
			color: #000000;
		}

		.line {
			width: 0;
			height: 16rpx;
			border-right: 1rpx solid #999999;
		}

		.name {
			font-size: 24rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFB800;
		}

		.imgBox {
			width: 49rpx;
			height: 49rpx;
		}
	}
</style>